{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a208184f",
   "metadata": {},
   "source": [
    "# 中文ai 地牢 colab"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e76affc5",
   "metadata": {},
   "source": [
    "- 点击\"代码执行程序\" -> \"全部运行\" 进行游戏\n",
    "- 安装依赖，下载模型和初始化大概会持续5分多钟时间\n",
    "- 如果模型输出的结果没对你的动作做出合理反应，或者一直重复某个事实，尝试忽略模型的重复，直接输入更加具体的你的动作，多几次总会走出来\n",
    "- 麻烦忽略模型输出中的一些逻辑问题，记住大体故事走向就好，这对游戏体验有好处（哈哈）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f83875f6",
   "metadata": {},
   "source": [
    "## 安装依赖"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "65c5e23f",
   "metadata": {},
   "outputs": [],
   "source": [
    "!git clone -q https://github.com/bupticybee/ChineseAiDungeon.git\n",
    "!mkdir -p /content/ChineseAiDungeon/models\n",
    "%cd /content/ChineseAiDungeon\n",
    "!pip3 install -r requirements.txt > tmp.log"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4ea1ab1a",
   "metadata": {},
   "source": [
    "## 下载模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ba291bf6",
   "metadata": {},
   "outputs": [],
   "source": [
    "!perl 3rd/gdown.pl/gdown.pl https://drive.google.com/open?id=1cJ1kvtPrV4TXxiadiGU6bJUAy11bRDm1 story_teller.zip\n",
    "!unzip story_teller.zip"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "648d01f2",
   "metadata": {},
   "source": [
    "## 初始化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "93b076ae",
   "metadata": {},
   "outputs": [],
   "source": [
    "from utils.story_helper import initize,Story\n",
    "initize(\"./tmp_weight/\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3f669cc8",
   "metadata": {},
   "source": [
    "# 开始游戏"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "10ad1a3f",
   "metadata": {},
   "outputs": [],
   "source": [
    "begin = f'''你在树林里冒险，指不定会从哪里蹦出来一些奇怪的东西，你握紧手上的手枪，希望这次冒险能够找到一些值钱的东西'''\n",
    "story = Story(begin)\n",
    "story.interactive()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ea34e2e9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "accelerator": "GPU",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
